package com.unicampmaps;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.view.Display;
import android.view.Gravity;
import android.view.Menu;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class ImageViewer extends Activity {

	public static Bitmap image;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_image_viewer);
		Display display = getWindowManager().getDefaultDisplay();
		
		ImageView imgView = new ImageView(this);
		imgView.setImageBitmap(image);
		LinearLayout l = (LinearLayout)findViewById(R.id.img_layout);
		l.setGravity(Gravity.CENTER);
		l.addView(imgView);
		
		imgView.setVisibility(ImageView.VISIBLE);

		int w = image.getWidth();
		int h = image.getHeight();
		
		float ratio = (float)display.getWidth()/w;
		
		imgView.setMinimumHeight((int)(ratio*h));
		imgView.setMinimumWidth((int)(ratio*w));
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.image_viewer, menu);
		return true;
	}

}
